home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
Tutorial
/
Cookbook
/
09.form
/
notes
< prev
next >
Wrap
Text File
|
1995-06-12
|
2KB
|
52 lines
Objective:
This module demonstrates a method to get a string value from a "Form"
or "Text" object into your C program. It is very similar to the C
to F caluclator with the exception that the "stringValue" method
is used instead of the "floatValueAt:" method. All the code is created by the Interface Builder with the exception of 4 lines.
Terms:
Discussion:
We will introduce the "stringValue" method in this module. It is used by several objects that have text strings that should be read
by another object.
Method:
1) Place a Form and a button on in the main window of a new application.
Create a subclass of Object with Outlet "myText" and Action "printText:".
Use the "New Object" selection from the main menu to create an instance
of it.
Connect the text up to the button with perform click. Connect the button
up to the Object with the printText action. Connect the Object to the
Form with the myText outlet selecting the Form rather than the Text.
Decompile. Add the following line to the printText method:
- printText:sender
{
char *strptr;
strptr = [myText stringValue];
printf("String = %s \n", strptr);
return self;
}
Add the following include file to the MyObject.m file:
#import <appkit/Form.h>
Do a Save from the interface builder and type "make".
Further Questions:
Take a look at the Spec Sheets for the Form and Text objects.
How are they different? Note that the Text object is one of
the most complex objects in the Appkit, but with it you can
easily build a simple text editor.
Summary: